home *** CD-ROM | disk | FTP | other *** search
- program Setup;
- { This is a stub program designed to copy the "real" install program to }
- { the hard disk, run the install, then terminate itself. }
- uses SysUtils, Utils, Dialogs, WinTypes, WinProcs;
-
- const
- ErrFailSpawn = 'Fatal Error: Failed to spawn INST.EXE. Error code: %d';
- ErrFailCopy = 'Fatal Error: Failed to copy files to temp directory';
-
- var
- S: String;
- a: array[0..255] of char;
- WEReturn: word;
- begin
- S := GetEnvVar('temp'); { find temp directory }
- if S = '' then S := 'c:\'; { use root if none exists }
- S := AddBackSlash(S);
- try
- CopyFile('inst.exe', S + 'inst.exe'); { copy install program }
- CopyFile('ddgsetup.ini', S + 'ddgsetup.ini'); { copy ini file }
- except
- on EInOutError do begin { if error copying files, }
- MessageDlg(ErrFailCopy, mtError, [mbOk], 0); { show message }
- Raise; { reraise exception to exit }
- end;
- end;
- StrPCopy(a, S + 'inst.exe foobar ' + ExtractFilePath(ParamStr(0)));
- WEReturn := WinExec(a, sw_ShowNormal); { execute install from HD }
- if WEReturn < 32 then { show error if exec fails }
- MessageDlg(Format(ErrFailSpawn, [WEReturn]), mtError, [mbOk], 0);
- end.